package com.doitedu.mr.day04.json;

import com.alibaba.fastjson.JSON;

import java.io.*;
import java.util.ArrayList;
import java.util.List;

/**
 * @Date 2021/12/3
 * @Created by HANGGE
 * @Description TODO
 */
public class JsonDemo {
    public static void main(String[] args) throws Exception {
        // 加载本地数据
        BufferedReader br = new BufferedReader(new FileReader("E:\\mrdata\\movie\\input\\rating.json"));
        List<Movie> movies = new ArrayList<Movie>() ;
        String  line = null ;
        while((line = br.readLine())!=null){
            try {
                // System.out.println(line);
                // 将本地数据转换成Javabean
                Movie movie = JSON.parseObject(line, Movie.class);// 注意解析异常
                System.out.println(movie);
                // 封装在集合中
                movies.add(movie) ;
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        System.out.println(movies.size());

    }
}
